import React from 'react';
import '../style.css';
import axios from 'axios'
import ListItems from './ListItems'


class List extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            items: []
        }
    }


    render() {
        return (
            <div className="list_container">
                    {
                        this.state.items.map((ele,index)=>{
                            return <ListItems item={ele} key={index} history={this.props.history}/>
                            
                        })
                    }
            </div>
        )
    }

    componentDidMount() {
        axios.get('http://localhost:3000/data.json').then((res) => {
            console.log(res.data.result.list)
            this.setState({
                items: res.data.result.list
            })
        }).catch((error) => {
            console.log(error)
        })
    }
}

export default List